IF INV_NBER<>VISIT1
   IF VISIT1=SPACE(7)
      DO PCON1200
      date1=date_visit
   ELSE
      IF VISIT2=SPACE(9)
         VISIT2=VISIT1
         date2=date1
         DO PCON1200
         date1=date_visit
      ELSE
         IF VISIT3=SPACE(9)
            VISIT3=VISIT2
            date3=date2
            VISIT2=VISIT1
            date2=date1
            DO PCON1200
            date1=date_visit
         ELSE
            IF VISIT4=SPACE(9)
               VISIT4=VISIT3
               date4=date3
               VISIT3=VISIT2
               date3=date2
               VISIT2=VISIT1
               date2=date1
               DO PCON1200
               date1=date_visit
            ELSE
               IF VISIT5=SPACE(9)
                  VISIT5=VISIT4
                  date5=date4
                  VISIT4=VISIT3
                  date4=date3
                  VISIT3=VISIT2
                  date3=date2
                  VISIT2=VISIT1
                  date2=date1
                  DO PCON1200
                  date1=date_visit
               ELSE
                  IF VISIT6=SPACE(9)
                     VISIT6=VISIT5
                     DATE6=DATE5
                     VISIT5=VISIT4
                     date5=date4
                     VISIT4=VISIT3
                     date4=date3
                     VISIT3=VISIT2
                     date3=date2
                     VISIT2=VISIT1
                     date2=date1
                     DO PCON1200
                     date1=date_visit
                  ELSE
                     IF VISIT7=SPACE(9)
                        VISIT7=VISIT6
                        DATE7=DATE6
                        VISIT6=VISIT5
                        DATE6=DATE5
                        VISIT5=VISIT4
                        date5=date4
                        VISIT4=VISIT3
                        date4=date3
                        VISIT3=VISIT2
                        date3=date2
                        VISIT2=VISIT1
                        date2=date1
                        DO PCON1200
                        date1=date_visit
                     ELSE
                        IF VISIT8=SPACE(9)
                           VISIT8=VISIT7
                           DATE8=DATE7
                           VISIT7=VISIT6
                           DATE7=DATE6
                           VISIT6=VISIT5
                           date6=date5
                           VISIT5=VISIT4
                           date5=date4
                           VISIT4=VISIT3
                           date4=date3
                           VISIT3=VISIT2
                           date3=date2
                           VISIT2=VISIT1
                           date2=date1
                           DO PCON1200
                           date1=date_visit
                        ELSE
                           IF VISIT9=SPACE(9)
                              VISIT9=VISIT8
                              DATE9=DATE8
                              VISIT8=VISIT7
                              DATE8=DATE7
                              VISIT7=VISIT6
                              DATE7=DATE6
                              VISIT6=VISIT5
                              date6=date5
                              VISIT5=VISIT4
                              date5=date4
                              VISIT4=VISIT3
                              date4=date3
                              VISIT3=VISIT2
                              date3=date2
                              VISIT2=VISIT1
                              date2=date1
                              DO PCON1200
                              date1=date_visit
                           ELSE
                              VISIT9=VISIT8
                              DATE9=DATE8
                              VISIT8=VISIT7
                              DATE8=DATE7
                              VISIT7=VISIT6
                              DATE7=DATE6
                              VISIT6=VISIT5
                              DATE6=DATE5
                              VISIT5=VISIT4
                              date5=date4
                              VISIT4=VISIT3
                              date4=date3
                              VISIT3=VISIT2
                              date3=date2
                              VISIT2=VISIT1
                              date2=date1
                              DO PCON1200
                              date1=date_visit
                           ENDIF
                        ENDIF
                     ENDIF
                  ENDIF
               ENDIF
            ENDIF
         ENDIF
      ENDIF
   ENDIF
ENDIF
